package com.training.menu.action.chengshu;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;


import org.apache.struts2.ServletActionContext;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.training.menu.service.chengshu.IMenuService;
import com.training.menu.service.impl.chengshu.MenuServiceImpl;
import com.training.pojo.chengshu.UFunction;
import com.training.pojo.chengshu.UUser;

@SuppressWarnings("serial")
public class LoadMenuAction extends ActionSupport  {
	
	private IMenuService menuSerice;
	private Map<String, List<UFunction>> mapmenu = new HashMap<String, List<UFunction>>(); 
	public void setMenuSerice(IMenuService menuSerice) {
		this.menuSerice = menuSerice;
		
	}
	public String execute(){
		@SuppressWarnings("unused")
		List<UFunction> uflist = new ArrayList<UFunction>();
		ActionContext actionContext = ActionContext.getContext();
		UUser user =  (UUser) actionContext.getSession().get("loginUser");
		uflist = menuSerice.menuService(user.getUid());
		mapmenu = menuSerice.menuListService(uflist,user.getUid());
		actionContext.getSession().put("mapmenu",mapmenu );
		return SUCCESS;
	}
}
